package chapter02

/**
 *
 * @author cdhuangchao3
 * @date 2023/6/3 8:04 PM
 */
object Test04_String {
  def main(args: Array[String]): Unit = {
    // 字符串，通过 '+' 连接
    val name = "aa" + "zs"
    val age = 18
    println(age + "岁的" + name + "在学习")

    // * 一个字符串复制多次拼接
    println(name * 3)

    // printf 通过%传值
    printf("%sb%d", name, age)

    // 字符串模板：通过$获取值
    println(s"$name + $age")
    println(s"${name} + ${age}")

    val num = 2.3456
    println(f"The num is ${num}%2.2f")
    println(raw"The num is ${num}%2.2f")

    // 三引号表示字符串
    val sql =
      s"""
         |select *
         |from tableA
         |where name='${name}'
         |""".stripMargin
    println(sql)
  }
}
